<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function fn(arr) {
        var add = +prompt('输入一个数字');
        var acc = +prompt('再输入一个数字');

        if (arr === '+') {
          alert(add + acc);
        } else if (arr === '-') {
          alert(add - acc);
        } else if (arr === '*') {
          alert(add * acc);
        } else if (arr === '/') {
          alert(add / acc);
        }
      }
      fn(prompt('请输入您要进行的运算'));
    </script>
  </body>
</html>
